import time

from selenium import webdriver
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC

driver = webdriver.Chrome()
driver.get("https://demoqa.com/dynamic-properties")
# visible_element = WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.ID, "visibleAfter")))
# print(visible_element.is_displayed())

# visible_element = WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.ID, "visibleAfter")))
# print(visible_element.is_displayed())

# click_element = driver.find_element(By.ID, "enableAfter")
# print(click_element)

# 等待元素可以点击
# click_element = WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.ID, "enableAfter")))
# print(click_element.is_enabled())

# click_element = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "enableAfter")))
# print(click_element.is_enabled())
driver.maximize_window()
# 等待内容发生变化
color_change = WebDriverWait(driver, 10).until(
    EC.text_to_be_present_in_element_attribute((By.ID, "colorChange"), "class", "text-danger"))
print(color_change)
time.sleep(5)
driver.quit()
